<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue2.4.4.js"></script>
</head>

<body>
    <div id="app">
        <!-- <input type="button" value="toggle" @click="toggle"> -->
        <input type="button" value="toggle" @click="flag=!flag">

        <!-- `v-if` 会进行 dom 的删除和创建操作， `v-show` 只是调整"display"属性的显示和隐藏-->
        <!-- `v-show` 有初始渲染消耗， `v-if` 有切换消耗 -->
        <h1 v-if="flag">'v-if'控制的元素</h1>
        <h1 v-show="flag">'v-show'控制的元素</h1>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                flag: true
            },
            methods: {
                toggle() {
                    this.flag = !this.flag;
                }
            }
        });
    </script>
</body>

</html>